package cn.edu.hitwh.kanlema.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Knife4jConfiguration {

	@Value("${swagger.enable}")
    private Boolean enable;

    @Bean(value = "defaultApi2")
    public Docket defaultApi2() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
        		.enable(enable)
                .apiInfo(
                	new ApiInfoBuilder()
							.title("看了吗接口文档测试")
							.description("看了吗接口文档测试")
							.contact(new Contact("vvcoder", "https://github.com/a-littlebit", "mzp.2005@qq.com"))
							.version("1.0")
							.build()
                )
				//分组名称
				.groupName("1.0版本")
				.select()
				//这里指定你自己的Controller扫描包路径
				.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
				.apis(RequestHandlerSelectors.basePackage("cn.edu.hitwh.kanlema.controller"))
				.paths(PathSelectors.any())
				.build();
        return docket;
    }
}
